<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>客户关系管理</title>
    <jsp:include page="../../head.jsp"/>
</head>
<script type="text/javascript">
    var formSetting = {
        title: "客户关系管理",
        module: 'query',
        columns: [{
            name: "name",
            label: "客户公司名称"
        }/* , {
         name : "CTIME",
         label : "上传日期从",
         type : "date"
         }, {
         name : "CTIME",
         label : "到",
         type : "date"
         } */],
        buttons: {
            custom: [
                {
                    id: "addbtn",
                    value: "添加到客户关系",
                    click: function () {
                        var selectedIds = $("#supCustomersDataGrid").jqGrid(
                                "getGridParam", "selarrrow");
                        if (selectedIds.length > 0) {
                            var data = "id=";
                            for (i in selectedIds) {
                                var ret = $("#supCustomersDataGrid").jqGrid('getRowData',
                                                                            selectedIds[i]);
                                data += ret.id + ",";
                            }
                            data = data.substring(0, data.length - 1);
                            $.ajax({
                                       url: "supCustomer-addBatch",
                                       dataType: "json",
                                       data: data,
                                       success: function (data) {
                                           jw.alert(data.msg);
                                       }
                                   });

                        } else {
                            jw.alert("请点击需要添加的数据!");
                        }
                    }
                }]
        },
        grid: {
            id: "supCustomersDataGrid",
            title: "查询结果",
            url: "supCustomer-findUCompanyList",
            multiselect: true,
            /* postData : {
             "pid" : pid
             }, */
            colModel: [{
                index: "ID",
                name: "id",
                hidden: true
            }, {
                index: "u_com_name",
                name: "name",
                label: "客户公司名称"
            }/*,  {
             index : "CTIME",
             name : "CTIME",
             label : "添加时间",
             formatter:'date',
             //sorttype:'date',
             //editrules:{date:true},
             //search:false,
             //editable:false,
             formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'}
             //datefmt:'Y-m-d H:i:s'
             } *//*, {
             index : "identifier",
             name : "identifier",
             label : "标识符"
             }, {
             index : "use_state",
             name : "use_state",
             label : "使用状态",
             formatter : function(cellvalue, options, rowObject) {
             if (cellvalue == "0") {
             return "启用";
             } else {
             return "禁用";
             }
             }
             }, {
             index : "updateUser",
             name : "updateUser",
             label : "修改人"
             }, {
             index : "updateDate",
             name : "updateDate",
             label : "修改时间"
             }  */],
            jsonReader: {
                userdata: "msg",
                root: "companys"
            },
            gridComplete: function () {
                var msg = $("#supCustomersDataGrid").jqGrid('getGridParam', 'userData');
                if (typeof msg == "string") {
                    jw.alert(msg);
                }
            }
        }
    };
    $(document).ready(function () {
        $("#supCustomersDataTable").mrdForm(formSetting);
    });
</script>
<body>
<div id="supCustomersDataTable"></div>
</body>
</html>
